package oop.java0321;

import java.util.Scanner;

public class MyClassTest {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        MyClass java78 = new MyClass();
        java78.name = "牛气哄哄的Java78班";
        java78.chargeTeacher = "李小莉";
        java78.date = "2022-02-01";
        while (true) {
            System.out.println("-----------------------------------");
            System.out.print("1.查看班级信息\n2.添加学生\n3.查找指定位置的学生\n" +
                    "4.修改信息\n5.查看学生信息及数量\n请选择：(输入0退出)");
            int no = in.nextInt();
            switch (no) {
                case 1: {
                    java78.showInfo();
                    break;
                }
                case 2: {
                    System.out.print("输入学生姓名：");
                    String name2 = in.next();
                    java78.addStudent(name2);
                    break;
                }
                case 3: {
                    System.out.print("请输入序号：");
                    int number3 = in.nextInt();
                    System.out.println(java78.showIndexInfo(number3));
                    break;
                }
                case 4: {
                    System.out.print("请输入要修改的学生姓名：");
                    String oldName = in.next();
                    System.out.print("请输入修改后的姓名：");
                    String newName = in.next();
                    boolean isFind = java78.update(oldName, newName);
                    if (!isFind) {
                        System.out.println("姓名不存在");
                        continue;
                    }
                    System.out.println("修改成功！");
                    break;
                }
                case 5: {
                    java78.showStudent();
                    break;
                }
                default: {
                    System.out.println("无效数字！");
                }
            }
            if (no == 0) {
                System.out.println("退出！");
                break;
            }
        }
    }
}
